﻿
Imports std
Imports occommon
Imports occommon.getResponse

Public Class userGet
    Inherits [get]

    Public Const _pathidentity As String = network.pathSeperator + path.userGet

    Shared Sub New()
        assert(Not strstartwith(path.userGet, network.pathSeperator))
    End Sub

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Protected Overrides Function useUserToLogin() As Boolean
        Return True
    End Function

    Private Shared Function responseUserSharedContent(ByVal user As String, ByRef content As String) As Boolean
        Dim s As String = Nothing
        Dim v As vector(Of String) = Nothing
        If userSharedCookies(user, s) OrElse userSites(user, v) Then
            If writeContent(content, contentNaming.sharedCookies, s) Then
                For i As Int64 = 0 To v.size() - 1
                    If Not writeContent(content, contentNaming.site, v(i)) Then
                        Return False
                    End If
                Next
            Else
                Return False
            End If
            Return True
        Else
            Return False
        End If
    End Function

    Private Shared Function responseUserSiteContent(ByVal user As String, ByVal site As String, _
                                                    ByRef content As String) As Boolean
        Dim s As String = Nothing
        If userSiteCookies(user, site, s) Then
            Return writeContent(content, site, s)
        Else
            Return False
        End If
    End Function

    Protected Overrides Function responseContent(ByVal site As String, _
                                                 ByVal user As String, _
                                                 ByRef content As String) As Boolean
        assert(Not isemptystring(user))
        If isemptystring(site) Then
            Return responseUserSharedContent(user, content)
        Else
            Return responseUserSiteContent(user, site, content)
        End If
    End Function
End Class
